<template>
	<view class="approval-footer">
		<view class="pass-footer">
			<view class="submit" @click="navTo()">驳回</view>
			<view class="pass" @click="handleConfirm()">审核通过</view>
			
		</view>
		<u-modal :show="showConfirm" @cancel="showConfirm=false" @confirm="submit" :showCancelButton="true"
			title="提示" content='是否确认提交?'></u-modal>
	</view>

</template>

<script>
	import {
		approveWorkOrder,
	} from '@/api/maintain.js'
	import {
		approveWorkOrderRepair
	} from '@/api/repair.js'
	import {
		approvePurchase
	} from '@/api/purchase.js'
	import {
		approveRequisition
	} from '@/api/requisition.js'
	export default {
		props: {
			id: {},
			type: {

			}, // 1保养工单,2维修工单，3：领用 4:请购
		},

		data() {
			return {
				approvalForm: {
					approvalResult: 1,
					remark: ''
				},
				showConfirm:false

			}
		},
		onLoad(option) {
			this.id = option.id || ''
			this.getDetail()
		},
		onShow() {

		},
		created() {

		},
		methods: {
			navTo() {
				uni.navigateTo({
					url: '/subMaintenance/wirteReson/index?id=' + this.id + '&type=' + this.type
				})
			},
			handleConfirm(){
				this.showConfirm=true
			},
			submit() {
				const paramData = {
					id: this.id,
					approvalResult: 1
				}
				this.showConfirm=false
				if (this.type === '1') {

					approveWorkOrder(paramData).then(response => {
						uni.showToast({
							icon: 'none',
							title: '提交成功',
							mask: true,
							duration: 2000,
						})
						this.$emit('getDetail')
					})
				}
				if (this.type === '2') {
					paramData.centerLeaderApproval = 0
					approveWorkOrderRepair(paramData).then(response => {
						uni.showToast({
							icon: 'none',
							title: '提交成功',
							mask: true,
							duration: 2000,
						})
						this.$emit('getDetail')
					})
				}
				if (this.type === '3') {

					approveRequisition(paramData).then(response => {
						uni.showToast({
							icon: 'none',
							title: '提交成功',
							mask: true,
							duration: 2000,
						})
						this.$emit('getDetail')
					})
				}


				if (this.type === '4') {

					approvePurchase(paramData).then(response => {
						uni.showToast({
							icon: 'none',
							title: '提交成功',
							mask: true,
							duration: 2000,
						})
						this.$emit('getDetail')
					})
				}
			}

		}
	}
</script>

<style lang="scss" scoped>
	.pass-footer {
		width: 690rpx;
		height: 104rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 70rpx auto 0 auto;

		.submit {
			background: #FF9F21;
			border-radius: 20rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 36rpx;
			font-weight: 400;
			color: #FFFFFF;
			width: 312rpx;
			height: 104rpx;
		}

		.pass {
			width: 312rpx;
			height: 104rpx;
			background: #407FFF;
			border-radius: 20rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 36rpx;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
</style>
